load("02_09_m5s_join_user_activity_df_univ_only.RData")


gender_sum_stats <- list()

gender_sum_stats[['tot']] <- table(unique(subset(join_user_activity_df_univ_only,
                                                 select=c("universal_id","gender")))$gender, useNA="always")

sources <- levels(join_user_activity_df_univ_only$source)
activities <- levels(join_user_activity_df_univ_only$activity)

for (what in c(sources, activities)) {
  col <- if (what %in% sources) "source" else "activity"
  gender_sum_stats[[what]] <- table(unique(subset(join_user_activity_df_univ_only,
                                                  get(col) == what,
                                                  select=c("universal_id","gender")))$gender, useNA="always")
}

lst_combinations <- list(c("facebook", "post"), c("facebook", "comment"), c("facebook", "like"),
                         c("blog","post"), c("blog","comment"))

for (what in lst_combinations) {
  gender_sum_stats[[paste0(what[1],"_",what[2])]] <- table(unique(subset(join_user_activity_df_univ_only,
                                                  source == what[1] & activity==what[2],
                                                  select=c("universal_id","gender")))$gender, useNA="always")
}
 
for (what in names(gender_sum_stats)) {
  print(what)
  print(prop.table(gender_sum_stats[[what]][1:2]))
}

save(gender_sum_stats, file="02_10_m5s_user_activity_df_univ_only_gender_stats.RData")
